package com.itheima.service.impl;

import com.itheima.dao.BookDao;
import com.itheima.service.BookService;

import java.util.Date;

/**
 * @author Xiao
 * @date 2021/9/11
 */
public class BookServiceImpl02 implements BookService {
    private BookDao bookDao;
    private String name;
    private int age;
    private Date birthday;

    public BookServiceImpl02(BookDao bookDao, String name, int age, Date birthday) {
        this.bookDao = bookDao;
        this.name = name;
        this.age = age;
        this.birthday = birthday;
    }

    public BookServiceImpl02() {
    }

    //提供setter方法
    public void setDate(Date birthday) {
        this.birthday = birthday;
    }

    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //业务逻辑
    public void save() {
        System.out.println("book service save...");
        System.out.println(name + "," + age + "," + birthday);
        bookDao.save();
    }
    //带参构造屏蔽无参构造时抛出异常 -->
    /*public BookServiceImpl(BookDao bookDao, String name, int age) {
        this.bookDao = bookDao;
        this.name = name;
        this.age = age;
    }*/
}
